	package org.android.brasil.projetos.oktoberfest2011.view;

	import java.util.List;

import org.android.brasil.projetos.oktoberfest2011.R;
import org.android.brasil.projetos.oktoberfest2011.negocio.model.Apresentacao;
import org.android.brasil.projetos.oktoberfest2011.persistencia.ApresentacaoDAO;
import org.android.brasil.projetos.oktoberfest2011.utils.ControleDeBackground;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;

	

public class DesfilesView extends ListActivity{

		private ListView lv;
		private List<Apresentacao> aprs;
		private OnClickListener casaListener = new OnClickListener() {

			public void onClick(View v) {
				setResult(RESULT_OK);
				finish();

			}
		};

		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);

			setContentView(R.layout.desfiles_view);
			bindScreenFields();
			populateFields();

		}

		private void populateFields() {
			ApresentacaoDAO.open(getApplicationContext());
			aprs = ApresentacaoDAO.consultarTodosDesfiles();
			ApresentacaoDAO.close();

			
			lv.setAdapter(new DesfilesAdapter(getApplicationContext(), aprs));

			
		}

		private void bindScreenFields() {
			lv = getListView();
			ImageView casa = (ImageView) findViewById(R.id.casa);
			casa.setOnClickListener(casaListener);
			
			RelativeLayout rl = (RelativeLayout) findViewById(R.idDesfiles.relativeLayout01);
			ControleDeBackground.SetBarraSuperiorBackGround(getApplicationContext(),rl);
			
		}


}
